/**
 * @(#)MapOverlay.java        1.0 4/11/12
 * 
 * Copyright (c) 2012 public static droid main
 * Georgia Institute of Technology, Atlanta, GA
 * All rights reserved.
 */
package edu.gatech.oad.publicstaticdroidmain.taskmanager.ui;

import java.util.LinkedList;
import java.util.List;

import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

/**
 * Holds the overlay items that are displayed on the map.
 * 
 * @author Raheel Merali
 */
public class MapOverlay extends ItemizedOverlay {

    private List<OverlayItem> mOverlays = new LinkedList<OverlayItem>();

    public MapOverlay(Drawable defaultMarker) {
	super(boundCenterBottom(defaultMarker));
    }

    /**
     * Adds the specified overlay to this MapOverlay.
     * 
     * @param overlay the overlay
     */
    public void addOverlay(OverlayItem overlay) {
	mOverlays.add(overlay);
	populate();
    }

    /**
     * Returns the overlay at the specified index.
     * 
     * @param i the index
     * @return the overlay at the specified index
     */
    protected OverlayItem createItem(int i) {
	return mOverlays.get(i);
    }

    /**
     * Returns the number of overlays in this MapOverlay.
     * 
     * @return the number of overlays in this MapOverlay
     */
    public int size() {
	return mOverlays.size();
    }

    /**
     * Called when an overlay on the Map is tapped.
     */
    public boolean onTap(int index) {
	System.out.println(mOverlays.get(index).getTitle());

	return true;
    }

}
